/*!
 Temelia - graph_t edge interface.
 Copyright (C) 2008 Ceata (http://cod.ceata.org/proiecte/temelia).

 This program is free software; you can redistribute it and
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 3
 of the License, or (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifndef EDGE_H_
#define EDGE_H_

#include "platform.h"
#include "graph_constants.h"
#include "vertex.h"

struct _edge_t;
typedef struct _edge_t *edge_t;

/*!
 * @brief Returns a new edge between vertices V1 and V2 with given cost and label.
 * Complexity O(1)
 *
 * @param First vertex
 * @param Second vertex
 * @param Edge cost
 * @param Edge label
 * @param Key attached to edge
 */
DECLSPEC edge_t edge_new(vertex_t vertex1, vertex_t vertex2, double cost, char *label,
		void *ket);

/*
 * @brief Frees memory occupied by an edge.
 * Complexity O(1)
 *
 * @param Edge
 */
DECLSPEC void edge_delete(edge_t edge);

/*!
 * @brief Returns first vertex of edge.
 * Complexity O(1)
 *
 * @param Edge
 */
DECLSPEC vertex_t edge_get_vertex1(edge_t edge);

/*!
 * @brief Returns second vertex of edge.
 * Complexity O(1)
 *
 * @param Edge
 */
DECLSPEC vertex_t edge_get_vertex2(edge_t edge);

/*!
 * @brief Returns complementary vertex of edge.
 * Complexity O(1)
 *
 * @param Edge
 * @param Pointer to vertex.
 */
DECLSPEC vertex_t edge_complementary_vertex(edge_t edge, vertex_t vertex);

/*!
 * @brief Returns edge cost.
 * Complexity O(1)
 *
 * @param Edge
 */
DECLSPEC double edge_get_cost(edge_t edge);

/*!
 * @brief Returns edge type.
 * Complexity O(1)
 *
 * @param Edge
 */
DECLSPEC char edge_get_type(edge_t edge);

/*!
 * @brief Returns edge's key.
 * Complexity O(1)
 *
 * @param Edge
 */
DECLSPEC void *edge_get_key(edge_t edge);

/*!
 * @brief Returns edge label.
 * Complexity O(1)
 *
 * @param Edge
 */
DECLSPEC char *edge_get_label(edge_t edge);

/*!
 * @brief Sets first vertex of edge.
 * Complexity O(1)
 *
 * @param Edge
 * @param Vertex
 */
DECLSPEC void edge_set_vertex1(edge_t edge, vertex_t vertex);

/*!
 * @brief Sets second vertex of edge.
 * Complexity O(1)
 *
 * @param Edge
 * @param Pointer to vertex
 */
DECLSPEC void edge_set_vertex2(edge_t edge, vertex_t vertex);

/*!
 * @brief Sets cost of edge.
 * Complexity O(1)
 *
 * @param Edge
 * @param New cost
 */
DECLSPEC void edge_set_cost(edge_t edge, double cost);

/*!
 * @brief Sets edge type.
 * Complexity O(1)
 *
 * @param Edge
 * @param New edge type
 */
DECLSPEC void edge_set_type(edge_t edge, char type);

/*!
 * @brief Sets key stored in edge.
 * Complexity O(1)
 *
 * @param Edge
 * @param New key
 */
DECLSPEC void edge_set_key(edge_t edge, void *key);

/*!
 * @brief Sets label of edge.
 * Complexity O(1)
 *
 * @param Edge
 * @param New label
 */
DECLSPEC void edge_set_label(edge_t edge, char *label);

/*!
 * @brief Debugs edge's content into a stream.
 *
 * @param Edge
 * @param Stream, should be FILE *
 */
DECLSPEC void edge_debug(edge_t edge, void *stream);

/*!
 * @brief Switches the orientation of edge: vertex1->vertex2
 * becomes vertex2->vertex1. It's common utility is in graph transposing.
 */
DECLSPEC void edge_switch_vertices(edge_t edge);

#endif /* EDGE_H_ */
